<!--继承基文件-->
{% extends "base.html" %}
{% load static %}
<!--标题-->
{% block title %} 编辑用户 {% endblock title %}
{% block user %}{% if request.session.user %}{{ request.session.user }}{% else %} administrator{% endif %}{% endblock %}

<!--内容-->
{% block content %}
    <div class="right-product my-index right-full">
        <div class="container-fluid">
            <div class="info-center">
                {% include 'content_head.html' %}

                <div class="content-list">
                    <div class="row newslist" style="margin-top:20px;">
                        <div class="col-md-12">
                            <div class="panel panel-info mystyle-panel">
                                <div class="panel-heading">
                                    编辑用户
                                    <div class="caret"></div>
                                    <a href="#" class="pull-right"><span class="glyphicon glyphicon-refresh"></span></a>
                                </div>
                                <div class="panel-body">
                                    <form class="form-horizontal" id="editUser" action="" method="post"
                                          onsubmit="return edituser_check();">
                                        {% csrf_token %}
                                        <div class="form-group" style="margin-top: 10px;">
                                            <label for="edit_user" class="col-sm-2 control-label">用户名</label>
                                            <div class="col-sm-10">
                                                <input type="text" value="{{ user_obj.username }}"
                                                       class="form-control myInput"
                                                       id="edit_user" name="username" readonly>
                                                <span class="myGray">必须为4-16位字母、数字或下划线，且以字母开头</span>
                                            </div>
                                        </div>
                                        <div class="form-group" style="margin-top: 10px;">
                                            <label for="edit_pwd" class="col-sm-2 control-label">密码</label>
                                            <div class="col-sm-10">
                                                <input type="password" value=""
                                                       style="width: 50%;display: inline-block"
                                                       class="form-control myInput"
                                                       id="edit_pwd" placeholder="请输入密码" name="password">
                                                <span class="myGray">密码必须为6-16位数字、英文字母或下划线</span>
                                            </div>
                                        </div>
                                        <div class="form-group" style="margin-top: 10px;">
                                            <label class="col-sm-2 control-label">性别</label>
                                            <div class="col-sm-10">
                                                {% if user_obj.gender == 'male' %}
                                                    <label class="radio-inline">
                                                        <input type="radio" name="gender" value="0" checked> 男
                                                    </label>
                                                    <label class="radio-inline">
                                                        <input type="radio" name="gender" value="1"> 女
                                                    </label>
                                                {% else %}
                                                    <label class="radio-inline">
                                                        <input type="radio" name="gender" value="0"> 男
                                                    </label>
                                                    <label class="radio-inline">
                                                        <input type="radio" name="gender" value="1" checked> 女
                                                    </label>
                                                {% endif %}
                                            </div>
                                        </div>
                                        <div class="form-group" style="margin-top: 10px;">
                                            <label for="edit_age" class="col-sm-2 control-label">年龄</label>
                                            <div class="col-sm-10">
                                                <input type="text" class="form-control myInput"
                                                       value="{{ user_obj.age }}"
                                                       id="edit_age" name="age">
                                                <span class="myGray">请输入两位整数</span>
                                            </div>
                                        </div>
                                        <div class="form-group" style="margin-top: 10px;">
                                            <label for="edit_email" class="col-sm-2 control-label">邮箱</label>
                                            <div class="col-sm-10">
                                                <input type="email" class="form-control myInput"
                                                       value="{{ user_obj.email }}"
                                                       id="edit_email" name="email">
                                                <span class="myGray">请输入正确的邮箱地址</span>
                                            </div>
                                        </div>
                                        <div class="form-group" style="margin-top: 10px;">
                                            <label for="edit_phone" class="col-sm-2 control-label">手机号</label>
                                            <div class="col-sm-10">
                                                <input type="text" class="form-control myInput"
                                                       value="{{ user_obj.phone }}"
                                                       id="edit_phone" name="phone">
                                                <span class="myGray">请输入手机号</span>
                                            </div>
                                        </div>
                                        <div class="form-group" style="margin-top: 10px;">
                                            <label class="col-sm-2 control-label">用户类型</label>
                                            <div class="col-sm-10">
                                                {% if user_obj.userType == 'general' %}
                                                    <label class="radio-inline">
                                                        <input type="radio" name="userType" value="general" checked>
                                                        普通用户
                                                    </label>
                                                    <label class="radio-inline">
                                                        <input type="radio" name="userType" value="admin"> 管理员
                                                    </label>
                                                {% else %}
                                                    <label class="radio-inline">
                                                        <input type="radio" name="userType" value="general"> 普通用户
                                                    </label>
                                                    <label class="radio-inline">
                                                        <input type="radio" name="userType" value="admin" checked> 管理员
                                                    </label>
                                                {% endif %}
                                            </div>
                                        </div>
                                        <div class="form-group" style="margin-top: 10px;">
                                            <div class="col-sm-offset-2 col-sm-10">
                                                <span style="color:red;">{{ error }}</span>
                                            </div>
                                        </div>
                                        <div class="form-group" style="margin-top: 10px;">
                                            <div class="col-sm-offset-2 col-sm-10">
                                                <input type="submit" class="btn btn-primary myInput" value="编辑">
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock content %}

<!--js文件-->
{% block jsFiles %}
    <script src="{% static 'js/myEditUser.js' %}"></script>
{% endblock jsFiles %}